package main

import (
	"fmt"
	"sort"
)

type GoodsDetail struct {
	Goods int32
	Num   int32
}

type GoodsDetailList []GoodsDetail

func (gdl *GoodsDetailList) Len() int {
	return len(*gdl)
}
func (gdl *GoodsDetailList) Less(i, j int) bool {
	return (*gdl)[i].Goods < (*gdl)[j].Goods
}
func (gdl *GoodsDetailList) Swap(i, j int) {
	(*gdl)[i], (*gdl)[j] = (*gdl)[j], (*gdl)[i]
}

func main() {
	goods := GoodsDetailList{
		{
			Goods: 10,
			Num:   10,
		},
		{
			Goods: 5,
			Num:   5,
		},
		{
			Goods: 3,
			Num:   3,
		},
		{
			Goods: 4,
			Num:   4,
		},
	}

	sort.Sort(&goods)
	fmt.Println(goods)
}
